package service.impl;

import java.util.Date;
import java.util.Set;

import dao.ActivitateDao;
import dao.AsistentDao;
import dao.DaoException;
import dao.SponsorDao;
import dao.VoluntarDao;

import model.Activitate;
import model.AsistentSocial;
import model.Sponsor;
import model.Voluntar;
import service.AdministratorService;
import service.ServiceException;

public class AdministratorServiceImpl implements AdministratorService {
	
	private SponsorDao sponsorDao;
	private AsistentDao asistentDao;
	private ActivitateDao activitDao;
	private VoluntarDao voluntarDao;

	public VoluntarDao getVoluntarDao() {
		return voluntarDao;
	}

	public void setVoluntarDao(VoluntarDao voluntarDao) {
		this.voluntarDao = voluntarDao;
	}

	public ActivitateDao getActivitDao() {
		return activitDao;
	}

	public void setActivitDao(ActivitateDao activitDao) {
		this.activitDao = activitDao;
	}

	public AsistentDao getAsistentDao() {
		return asistentDao;
	}

	public void setAsistentDao(AsistentDao asistentDao) {
		this.asistentDao = asistentDao;
	}

	public SponsorDao getSponsorDao() {
		return sponsorDao;
	}

	public void setSponsorDao(SponsorDao sponsorDao) {
		this.sponsorDao = sponsorDao;
	}

	@Override
	public void addAsistent(String nume, String prenume, String cnp, String adresa, String telefon) {
		AsistentSocial a=new AsistentSocial();
		a.setUserId(asistentDao.getMaxId()+1);
		a.setNume(nume);
		a.setPrenume(prenume);
		a.setCnp(cnp);
		a.setAdresa(adresa);
		a.setTelefon(telefon);
		asistentDao.addOrUpdateAsistent(a);
		
	}

	@Override
	public void updateAsistent(AsistentSocial asistent) {
		asistentDao.addOrUpdateAsistent(asistent);
		
	}

	@Override
	public void removeAsistent(int id) throws ServiceException {
		try {
			asistentDao.removeAsistent(id);
		} catch (DaoException e) {
			// TODO Auto-generated catch block
			 throw new ServiceException(e.getMessage());
		}
		
	}

	@Override
	public Set<AsistentSocial> getAsistenti() {
		
		return asistentDao.getAllAsistenti();
	}

	@Override
	public void addActivitate(String denumire, Date data, String locatie) {
		Activitate ac=new Activitate();
		ac.setActivitateId(activitDao.getMaxId()+1);
		ac.setDenumire(denumire);
		ac.setData(data);
		ac.setLocatia(locatie);
		activitDao.addOrUpdateActivitate(ac);
		
	}

	@Override
	public void updateActivitate(Activitate activitate) {
		activitDao.addOrUpdateActivitate(activitate);
		
	}

	@Override
	public void removeActivitate(int id) throws ServiceException {
		try {
			activitDao.removeActivitate(id);
		} catch (DaoException e) {
			// TODO Auto-generated catch block
			 throw new ServiceException(e.getMessage());
		}
		
	}

	@Override
	public Set<Activitate> getActivitati() {
		
		return activitDao.getAllActivitati();
	}

	@Override
	public void addSponsor(String nume, Integer suma,String adresa, String telefon,  String cnp) {
		Sponsor s=new Sponsor();
		s.setSponsorId(sponsorDao.getMaxId()+1);
		s.setNume(nume);
		s.setSuma(suma);
		s.setAdresa(adresa);
		s.setTelefon(telefon);
		s.setCnp(cnp);
		sponsorDao.addOrUpdateSponsor(s);
		
	}

	@Override
	public void updateSponsor(Sponsor sponsor) {
		sponsorDao.addOrUpdateSponsor(sponsor);
		
	}

	@Override
	public void removeSponsor(int id) throws ServiceException {
		try {
			sponsorDao.removeSponsor(id);
		} catch (DaoException e) {
			// TODO Auto-generated catch block
			 throw new ServiceException(e.getMessage());
		}
		
	}

	@Override
	public Set<Sponsor> getSponsori() {
		return sponsorDao.getAllSponsori();
	}

	@Override
	public void addVoluntar(String nume, String prenume, String cnp, String adresa, String telefon) {
		Voluntar v=new Voluntar();
		v.setVoluntarId(voluntarDao.getMaxId()+1);
		v.setNume(nume);
		
		v.setCnp(cnp);
		v.setAdresa(adresa);
		v.setTelefon(telefon);
		
	}

	@Override
	public void updateVoluntar(Voluntar voluntar) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removeVoluntar(int id) throws ServiceException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Set<Voluntar> getVoluntari() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Sponsor getSponsorById(int id) throws ServiceException {
		
		try {
			return sponsorDao.getSponsorByID(id);
		} catch (DaoException e) {
			// TODO Auto-generated catch block
			 throw new ServiceException(e.getMessage());
		}
	}

	
}
